﻿using INTEX.DataBase;
using ReflectionStudio.Components.UserControls;
using ReflectionStudio.Core.Events;
using ReflectionStudio.Core.Helpers;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OracleClient;
using System.Windows;
using System.Windows.Data;
using System.Windows.Input;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for SETUPABON.xaml
    /// </summary>
    public partial class ITXSETUP
    { 
  
         #region=======GABBS=========
        private void butNEWGABBS_Click(object sender, RoutedEventArgs e)
        {
            DataSet setResult = null;
            try
            {
                if (dwGABBS == null)
                    return;
                DataRow dwNew = SetDetail.ICC_GABBS.NewRow();
                dwNew.ItemArray =dwGABBS.ItemArray;
                dwNew["ROWNID"] = "0";
                SetDetail.ICC_GABBS.Rows.Add(dwNew);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        private void butGABBSLoad_Click(object sender, RoutedEventArgs e)
        {
            DataSet setResult = null;
            try
            {
                setResult = m_Data.LoadGABBS(Mandant);
                SetMaster.Clear();
                SetMaster.Merge(setResult, false, MissingSchemaAction.Ignore);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            } 
        }
        private void butGABBSCopy_Click(object sender, RoutedEventArgs e)
        {
            DataSet setResult = null;
            try
            {
                if (dwGABBS == null)
                    return;
                DataRow dwNew = SetDetail.ICC_GABBS.NewRow();
                dwNew.ItemArray = dwGABBS.ItemArray;
                dwNew["ROWNID"] = "0";
                dwNew["MLLOC"] = txtMLloc.Text.Trim();
                SetDetail.ICC_GABBS.Rows.Add(dwNew);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        private void butGABBSEdit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                SetDetail.Clear();
                SetDetail.Merge(SetMaster.ICC_GABBS);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);

            }
            finally
            {

            }
        }
        private void butGABBSCopyAll_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                SetDetail.Clear();
                SetDetail.Merge(SetMaster.ICC_GABBS);
                foreach (DataRow RX in SetDetail.ICC_GABBS.Rows)
                {
                    RX["ROWNID"] = "0";
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);

            }

        }
        private void butGABBSSave_Click(object sender, RoutedEventArgs e)
        {
            DataSet setResult = null;
            try
            {
                m_Data.SaveGABBS(SetDetail, "00");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        #endregion 
    }
}
